package com.tcu.order.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.tcu.order.entity.OrderPicture;
import com.tcu.order.mapper.OrderPictureMapper;
import com.tcu.order.service.IOrderPictureService;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class OrderPictureServiceImpl extends ServiceImpl<OrderPictureMapper, OrderPicture> implements IOrderPictureService {
    @Override
    public List<OrderPicture> getPicturesByOrderId(String orderId) {
        QueryWrapper<OrderPicture> wrapper = new QueryWrapper<>();
        wrapper.eq("order_id",orderId);
        List<OrderPicture> orderPictures = baseMapper.selectList(wrapper);
        return orderPictures;
    }

    @Override
    public Integer deletePicturesByOrderId(String orderId) {
        QueryWrapper<OrderPicture> wrapper = new QueryWrapper<>();
        wrapper.eq("order_id",orderId);
        int delete = baseMapper.delete(wrapper);
        return delete;
    }

    @Override
    public List<OrderPicture> getSomePictures(String orderId, Integer isUser) {
        QueryWrapper<OrderPicture> wrapper = new QueryWrapper<>();
        wrapper.eq("order_id",orderId).eq("is_user",isUser);
        List<OrderPicture> orderPictures = baseMapper.selectList(wrapper);
        return orderPictures;
    }
}
